******
* This script configures the Stata library environment and displays the value of system parameters
******
* Stata version control
version 18

* Seed
global seed 2148

* Ensure Stata uses only local libraries and programs
tokenize `"$S_ADO"', parse(";")
while `"`1'"' != "" {
  if `"`1'"'!="BASE" cap adopath - `"`1'"'
  macro shift
}
adopath ++ "${ProjectDir}/scripts/libraries/stata"
adopath ++ "${ProjectDir}/scripts/programs"
mata: mata mlib index

* Display system parameters and record the date and time
cap program drop _print_timestamp 
program define _print_timestamp 
	di "{hline `=min(79, c(linesize))'}"

	di "Date and time: $S_DATE $S_TIME"
	di "Stata version: `c(stata_version)'"
	di "Updated as of: `c(born_date)'"
	di "Variant:       `=cond( c(MP),"MP",cond(c(SE),"SE",c(flavor)) )'"
	di "Processors:    `c(processors)'"
	di "OS:            `c(os)' `c(osdtl)'"
	di "Machine type:  `c(machine_type)'"
	local hostname : env HOSTNAME
	if !mi("`hostname'") di "Hostname:      `hostname'"
	
	di "{hline `=min(79, c(linesize))'}"
end
noi _print_timestamp

* Create directories for output files
cap mkdir "${ProjectDir}/data"
cap mkdir "${ProjectDir}/temp"
cap mkdir "${ProjectDir}/results"
cap mkdir "${ProjectDir}/results/graphs"
cap mkdir "${ProjectDir}/results/tables"

* Paths
global scripts 		"${ProjectDir}/scripts/"
global rawdata 		"${ProjectDir}/rawdata/"
global data 		"${ProjectDir}/data/"
global temp 		"${ProjectDir}/temp/"
global programs 	"${ProjectDir}/scripts/programs/"
global results 		"${ProjectDir}/results/"
global graphpath 	"${ProjectDir}/results/graphs/"
global tablepath 	"${ProjectDir}/results/tables/"
global paper_tables "${ProjectDir}/paper/tables/"
global paper_graphs "${ProjectDir}/paper/graphs/"

* Additional settings
set varabbrev off
set more off

